package com.xzl.shop.job;

import com.xzl.shop.model.Goods2;
import com.xzl.shop.server.Goods2Server;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;

import java.util.Date;
import java.util.List;

@Component
@Slf4j
public class Task {
    @Autowired
    private Jedis jedis;
    @Autowired
    private Goods2Server goods2Server;
    @Scheduled(cron = "0 * * * * ?")
    public void task1(){
        List<Goods2> list = goods2Server.queryNew();

        for(int i = 0; i < list.size(); i++){
            jedis.hset("h"+i,list.get(i).toHash());
        }
        System.out.println("now time is "+ new Date());
    }
}
